﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace VK.Casemeet.ADs
{
    public static class ADHelper
    {
        public static string GetTargetLabel(int target)
        {
            string result = string.Empty;
            switch (target)
            {
                case 1: result = "页内跳转"; break;
                case 2: result = "新建窗口"; break;
            }
            return result;
        }

        public static void BindTargetRAD(RadioButtonList radlst)
        {
            radlst.Items.Clear();
            radlst.Items.Add(new ListItem("页内跳转", "1"));
            radlst.Items.Add(new ListItem("新建窗口", "2"));
            radlst.SelectedIndex = 0;
        }

        public static string GetADHtml(string code, int provinceID, int cityID)
        {
            string result = string.Empty;
            ADEntity ad = ADBLL.GetAD(code, provinceID, cityID);
            if(ad!=null)
                result = "<a href='" + ad.Url + "' target='" + ad.TargetStr + "'><img alt='' src='/UserImages/ADs/" +
                    ad.Image + "' class='left' style='width:" + ad.Width + "px;height:" + ad.Height + "px;' /></a>";
            
            return result;
        }
    }
}
